<template>
	<view>
		<view class="row-item">
			<view class="type-text">收件人姓名：</view>
			<input placeholder="请输入收件人姓名" v-model="addressInfo.name" />
		</view>
		<view class="row-item">
			<view class="type-text">收件人电话：</view>
			<input placeholder="请输入收件人电话" v-model="addressInfo.mobile" />
		</view>
		<view class="row-item" @click="selectDistrict">
			<view class="type-text">所在地区：</view>
			<view v-if="addressInfo.province">{{addressInfo.province}}{{addressInfo.city}}{{addressInfo.district}}
			</view>
			<view v-else class="area-text">请选择地区</view>
		</view>
		<view class="row-item">
			<view class="type-text">详细地址：</view>
			<textarea class="textarea" placeholder="街道、楼牌号等" v-model="addressInfo.address"></textarea>
		</view>
		<view class="row-item default-view">
			<view>
				<view>设置默认地址</view>
				<view class="hint-text">提示：每次下单会默认推荐使用该地址</view>
			</view>
			<switch color="#a20000" style="transform:scale(0.7)" :checked="addressInfo.default" />
		</view>
		<view class="saveButton" @click="saveAction">保存</view>
	</view>
</template>

<script>
	export default {
		name: "wts-addressAdd",
		props: {
			addressInfo: '',
		},
		data() {
			return {

			}
		},
		watch: {

		},
		methods: {
			// 选择地区
			selectDistrict() {
				this.$emit('selectDistrict')
			},
			// 保存
			saveAction() {
				this.$emit('saveAction')
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.row-item {
		background-color: #fff;
		padding: 30rpx;
		border-bottom: #eee 2rpx solid;
		display: flex;
		font-size: 28rpx;

		.type-text {
			width: 200rpx;
			font-size: 28rpx;
		}

		input {
			font-size: 28rpx;
		}

		.area-text {
			color: gray;
			font-size: 28rpx;
		}

		&:last-of-type {
			border-bottom: none;
		}

		.textarea {
			flex: 1;
			height: 120rpx;
			font-size: 28rpx;
		}
	}

	.default-view {
		font-size: 28rpx;
		margin-top: 30rpx;
		justify-content: space-between;

		.hint-text {
			color: #666;
			font-size: 26rpx;
			margin-top: 10rpx;
		}
	}

	.saveButton {
		background-color: #a20000;
		color: #fff;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		border-radius: 10rpx;
		margin: 50rpx;
	}
</style>